package spring.angularjs.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import spring.angularjs.dao.AddressBookDAO;
import spring.angularjs.dao.ToDoDAO;
import spring.angularjs.domain.Addressbook;
import spring.angularjs.domain.Todo;

@Service
public class ServicesImpl implements Services {
	
	@Autowired
	private ToDoDAO todoDAO;
	
	@Autowired
	private AddressBookDAO addressbookDAO;

	@Override
	@Transactional
	public List<Todo> getListTodo() {
		return todoDAO.getList();
	}

	@Override
	@Transactional
	public Todo getTodo(int id) {
		return todoDAO.getTodo(id);
	}

	@Override
	@Transactional
	public void addTodo(Todo todo) {
		todoDAO.addTodo(todo);
	}

	@Override
	@Transactional
	public void deleteTodo(Todo todo) {
		todoDAO.deleteTodo(todo);
	}

	@Override
	@Transactional
	public void deleteAllTodo() {
		todoDAO.deleteAll();
	}

	@Override
	@Transactional
	public void updateTodo(Todo todo) {
		todoDAO.updateTodo(todo);
	}

	@Override
	@Transactional
	public void addAddressBook(Addressbook ab) {
		addressbookDAO.addAddressBook(ab);
	}

	@Override
	@Transactional
	public void deleteAllAddressBook() {
		addressbookDAO.deleteAll();
	}

	@Override
	@Transactional
	public void deleteAddressBook(Addressbook ab) {
		addressbookDAO.deleteAddressBook(ab);
	}

	@Override
	@Transactional
	public List<Addressbook> getListAddressbook() {
		return addressbookDAO.getList();
	}

	@Override
	@Transactional
	public Addressbook getAddressbook(int idab) {
		return addressbookDAO.getAddressbook(idab);
	}

	@Override
	@Transactional
	public void updateAddressbook(Addressbook ab) {
		addressbookDAO.updateAddressbook(ab);
	}

}
